% IRFINI.m
%
% Date Created: 5-May-2008
% Last Modified:3-June-2011
%
% NOTE: Needs solution matrices from SMATS.m for initial structure
%       Requires IRFSIM.m to be run before 


[n l] = size(PSI);

% Set options
% up_to = 16; % Horizon of the response is set in IRFSIM.m
shocks = l;

% Note: Standard deviation to the same values as in IRFFIN.m
% and IRFSIM.m

Omega = [siga  0   0    0;
          0  sige  0    0;
          0    0  sigz  0;
          0    0    0   sigr];

imp = Omega;
time = 1:up_to;

yirfini_1 = zeros(n,up_to);
yirfini_2 = zeros(n,up_to);
yirfini_3 = zeros(n,up_to);
yirfini_4 = zeros(n,up_to);


% Impulse response to ea(t)
yirfini_1(:,1) = inv(eye(n)-S1_i)*S0_i + S2_i*imp(:,1);
for t = 1:(up_to-1)
    yirfini_1(:,t+1) = S0_i + S1_i*yirfini_1(:,t);
end

% Impulse response to ee(t)
yirfini_2(:,1) = inv(eye(n)-S1_i)*S0_i+S2_i*imp(:,2);
for t = 1:(up_to-1)
    yirfini_2(:,t+1) = S0_i +S1_i*yirfini_2(:,t);
end

% Impulse response to ev(t)
yirfini_3(:,1) = inv(eye(n)-S1_i)*S0_i+S2_i*imp(:,3);
for t = 1:(up_to-1)
    yirfini_3(:,t+1) = S0_i +S1_i*yirfini_3(:,t);
end

% Impulse response to ez(t)
yirfini_4(:,1) = inv(eye(n)-S1_i)*S0_i+S2_i*imp(:,4);
for t = 1:(up_to-1)
    yirfini_4(:,t+1) = S0_i +S1_i*yirfini_4(:,t);
end

%% Transformation of Units
% For shock 1
output_resp_ini_1 = yirfini_1(1,:);
g_resp_ini_1 = 400*yirfini_1(4,:);
inflation_resp_ini_1 = yirfini_1(2,:)*400;
r_resp_ini_1 = yirfini_1(3,:)*400;
inflationE_resp_ini_1 = yirfini_1(6,:)*400;
realr_resp_ini_1 = r_resp_ini_1 - inflationE_resp_ini_1;



